package com.fattyCorps.game.controller;

import com.fattyCorps.game.obj.msg.SRet;
import com.fattyCorps.game.service.TavernService;
import com.fattyCorps.game.util.GameJwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/tavern")
public class TavernController {

    @Autowired
    TavernService tavernService;

    @PostMapping("/getTavernInfo")
    public SRet getTavernInfo(HttpServletRequest request){
        Integer playerId = GameJwtUtils.getPlayerIdByRequest(request);
        SRet ret = tavernService.getTavernInfo(playerId);
        return ret;
    }

    @PostMapping("/freeLottery")
    public SRet freeLottery(HttpServletRequest request){
        Integer playerId = GameJwtUtils.getPlayerIdByRequest(request);
        SRet ret = tavernService.freeLottery(playerId);
        return ret;
    }

    @PostMapping("/oneCoinLottery")
    public SRet oneCoinLottery(HttpServletRequest request){
        Integer playerId = GameJwtUtils.getPlayerIdByRequest(request);
        SRet ret = tavernService.oneCoinLottery(playerId);
        return ret;
    }

    @PostMapping("/tenCoinLottery")
    public SRet tenCoinLottery(HttpServletRequest request){
        Integer playerId = GameJwtUtils.getPlayerIdByRequest(request);
        SRet ret = tavernService.tenCoinLottery(playerId);
        return ret;
    }

    @PostMapping("/oneItemLottery")
    public SRet oneItemLottery(HttpServletRequest request){
        Integer playerId = GameJwtUtils.getPlayerIdByRequest(request);
        SRet ret = tavernService.oneItemLottery(playerId);
        return ret;
    }

    @PostMapping("/tenItemLottery")
    public SRet tenItemLottery(HttpServletRequest request){
        Integer playerId = GameJwtUtils.getPlayerIdByRequest(request);
        SRet ret = tavernService.tenItemLottery(playerId);
        return ret;
    }
}
